#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi


#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > cc_energy_triplet.info <<'%EOF%'
   cc_energy_triplet
   -----------------
   Molecule:         CH
   Wave Function:    CCS, CC2, CCSD / cc-pVDZ
   Test Purpose:     Triplet excitation energies
%EOF%

#######################################################################
#  INTEGRAL INPUT
#######################################################################
cat > cc_energy_triplet.mol <<'%EOF%'
BASIS
cc-pVDZ
C2H2 in cc-pVDZ basis set
Exp. geo. from Baldacci et al.
    2    3  X  Y  Z 1.00D-18
        6.    1
C1    .000000  .000000  1.136264
        1.    1
H1    .000000  .000000  3.143437        
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > cc_energy_triplet.dal <<'%EOF%'
**DALTON INPUT
.RUN WAVE FUNCTIONS
**WAVE FUNCTIONS
.TITLE
  Triplet excitation energies
.CC
*SCF INPUT 
.THRESH
 1.0D-10
*CC INPUT 
.CCS
.CC2
.CCSD
.THRENR
 1.0d-10
.PRINT
  1
*CCEXCI
.NCCEXCI
 1 2 1 2 1 2 0 1 
 2 4 2 2 2 4 0 2
.THREXC
 1.0D-10
**END OF DALTON INPUT
%EOF%
#######################################################################

 

#######################################################################
#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >cc_energy_triplet.check
cat >>cc_energy_triplet.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

# SCF, MP2 and CCSD energies:
CRIT1=`$GREP "Final * HF energy:" $log | $GREP "\-76.82577561" | wc -l`
CRIT2=`$GREP "Total MP2   energy:                   \-77.08583480" $log | wc -l`
CRIT3=`$GREP "Total CC2   energy:                   \-77.08936011" $log | wc -l`
CRIT4=`$GREP "Total CCSD  energy:                   \-77.10253064" $log | wc -l`
TEST[1]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4`
CTRL[1]=7
ERROR[1]="ENERGIES NOT CORRECT"


# CCS excitation energies:
CRIT1=`$GREP "\^1Ag  \|    1   \|     ( |0)\.628157.  \|      17\.0930.  \|    137864\....  \| 100\.00" $log | wc -l`
CRIT2=`$GREP "\^3Ag  \|    2   \|     ( |0)\.643891.  \|      17\.5211.  \|    141317\....  \| 100\.00" $log | wc -l`
CRIT3=`$GREP "\^3B3u \|    3   \|     ( |0)\.577372.  \|      15\.7111.  \|    126718\....  \| 100\.00" $log | wc -l`
CRIT4=`$GREP "\^3B(2|3)u \|    2   \|     ( |0)\.557738.  \|      15\.1768.  \|    122409\....  \| 100\.00" $log | wc -l`
CRIT5=`$GREP "\^1B1u \|    1   \|     ( |0)\.253096.  \|       6\.887..  \|     55548\....  \| 100\.00" $log | wc -l`
CRIT6=`$GREP "\^3B2g \|    1   \|     ( |0)\.346074.  \|       9\.4171.  \|     75954\....  \| 100\.00" $log | wc -l`
CRIT7=`$GREP "\^3B2g \|    3   \|     ( |0)\.560908.  \|      15\.2631.  \|    123105\....  \| 100\.00" $log | wc -l`
CRIT8=`$GREP "\^1Au  \|    1   \|     ( |0)\.238794.  \|       6\.4979.  \|     52409\....  \| 100\.00" $log | wc -l`
CRIT9=`$GREP "\^3Au  \|    2   \|     ( |0)\.238794.  \|       6\.4979.  \|     52409\....  \| 100\.00" $log | wc -l`
TEST[2]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6 \+ $CRIT7 \+ $CRIT8 \+ $CRIT9`
CTRL[2]=10
ERROR[2]="CCS EXCITATION ENERGIES NOT CORRECT"


# CC2 excitation energies:
CRIT1=`$GREP "\^1Ag  \|    1   \|     ( |0)\.599132.  \|      16\.3032.  \|    131494\....  \|  " $log | wc -l`
CRIT2=`$GREP "\^3Ag  \|    2   \|     ( |0)\.630165.  \|      17\.1476.  \|    138305\....  \|  " $log | wc -l`
CRIT3=`$GREP "\^3B3u \|    4   \|     ( |0)\.932386.  \|      25\.3715.  \|    204635\....  \|  " $log | wc -l`
CRIT4=`$GREP "\^3B(2|3)u \|    2   \|     ( |0)\.552446.  \|      15\.0328.  \|    121247\....  " $log | wc -l`
CRIT5=`$GREP "\^3B1g \|    2   \|     ( |0)\.732147.  \|      19\.9227.  \|    160687\....  \|  " $log | wc -l`
CRIT6=`$GREP "\^3B1u \|    2   \|     ( |0)\.252231.  \|       6\.8635.  \|     55358\....  \|  " $log | wc -l`
CRIT7=`$GREP "\^3B2g \|    4   \|     ( |0)\.764515.  \|      20\.8035.  \|    167791\....  \|  " $log | wc -l`
CRIT8=`$GREP "\^3Au  \|    1   \|     ( |0)\.252231.  \|       6\.8635.  \|     55358\....  \|  " $log | wc -l`
CRIT9=`$GREP "\^3Au  \|    2   \|     ( |0)\.282015.  \|       7\.6740.  \|     61895\....  \|  " $log | wc -l`
TEST[3]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6 \+ $CRIT7 \+ $CRIT8 \+ $CRIT9`
CTRL[3]=10
ERROR[3]="CC2 EXCITATION ENERGIES NOT CORRECT"


# CCSD excitation energies:
CRIT1=`$GREP "\^3Ag  \|    1   \|     ( |0)\.5235805  \|      14\.2473.  \|    114912\....  \|  " $log | wc -l`
CRIT2=`$GREP "\^3B(2|3)u \|    2   \|     ( |0)\.5436939  \|      14\.7946.  \|    119327\....  \|  " $log | wc -l`
CRIT3=`$GREP "\^3B3u \|    4   \|     ( |0)\.7148328  \|      19\.451..  \|    156887\....  \|  " $log | wc -l`
CRIT4=`$GREP "\^3B1g \|    1   \|     ( |0)\.5669980  \|      15\.4288.  \|    124441\....  \|  " $log | wc -l`
CRIT5=`$GREP "\^3B1g \|    2   \|     ( |0)\.6128698  \|      16\.6770.  \|    134509\....  \|  " $log | wc -l`
CRIT6=`$GREP "\^3B2g \|    1   \|     ( |0)\.3476942  \|       9\.4612.  \|     76310\....  \|  " $log | wc -l`
CRIT7=`$GREP "\^3B2g \|    2   \|     ( |0)\.4730839  \|      12\.8732.  \|    103829\....  \|  " $log | wc -l`
CRIT8=`$GREP "\^3B2g \|    4   \|     ( |0)\.7362316  \|      20\.0338.  \|    161584\....  \|  " $log | wc -l`
CRIT9=`$GREP "\^3Au  \|    1   \|     ( |0)\.2473476  \|       6\.7306.  \|     54286\....  \|  " $log | wc -l`
TEST[4]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6 \+ $CRIT7 \+ $CRIT8 \+ $CRIT9`
CTRL[4]=10
ERROR[4]="CCSD EXCITATION ENERGIES NOT CORRECT"


PASSED=1
for i in 1 2 3 4
do
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM
  exit 1
fi                
%EOF%
#######################################################################
